<?php

namespace App\Http\Controllers;
use App\Comment;

use Illuminate\Http\Request;

class CommentController extends Controller
{
    public function fetch_comment(Request $request)
    {
	$comments = Comment::where('student_id', $request->student_id)->where(function ($query) use($request){
		 $query->where('type', $request->type)->orWhere('type', $request->type + 1000);
	});
        return redirect()->back();
    }

    public function store_comment(Request $request)
    {
	$comment = new Comment;
	$comment->student_id = $request->student_id;
	$comment->supervisor_id = 1;
	$comment->comment = $request->comment;
	$comment->type = $request->type;
	$comment->save();
        return redirect()->back();
    }

}
